package com.example.cracker1116;

public class RandomGen {
	
	private int lastValue;
	private int seed;
	int ConstantValue;
	
	public RandomGen(int seed) {
		ConstantValue = 0x1df5e0d;
		lastValue = 0;
		this.seed = seed;
	}
	
	public int getNext() {
		int product1 = 0; 		// v0
		int product2 = 0;		// v1
		int product3 = 0;		// v2
		int sum = 0;			// v3
		int finalValue = 0;		// v6
		
		product1 = (lastValue / 0x2710) * (ConstantValue % 0x2710);
		product2 = (ConstantValue / 0x2710) * (lastValue % 0x2710);
		product3 = (ConstantValue % 0x2710) * (lastValue % 0x2710);
		
		int temp = product1 + product2;
		temp %= 0x2710;
		temp *= 0x2710;
		sum = temp + product3;
		
		temp = sum % 0x5f5e100;
		temp += 1;
		lastValue = temp;
		
		long tempVal = 0; 			// v9
		long multResult = 0;		// v7
		long TempResult = 0; 		// v4
		
		tempVal = lastValue % 0x5f5e100;
		multResult = tempVal / 0x2710 * seed;
		multResult &= 0xffffffffL;
		TempResult = multResult / 0x2710;
		
		if (TempResult != 0) {
			if ((TempResult % 4) != 0) {
				finalValue = (int)TempResult;
				finalValue = finalValue >> 2;
				finalValue *= 4;
				finalValue += 4;
			} else {
				finalValue = (int)TempResult;
			}
		} else {
			finalValue = 0x5f5e100;
		}
		return finalValue;
	}
}
